/*
 * Exploder
 * 
 * Tero Pyylampi (218437), Jussi Tuurinkoski (211594)
 *
 * Main game engine
 */

#ifndef GAMEENGINE_H
#define GAMEENGINE_H

#include "cocos2d.h"
#include "Box2D/Box2D.h"

class GameScene;
class GameCamera;
class LayerGame;
class GameLevelEngine;
class GameClouds;
class MainEngine;
class GameAbstractEngine;
class GamePhysicObjectEngine;

enum GameState { GAME_RUNNING, GAME_WON, GAME_LOST };

class GameEngine {
public:
	// default constructor
	GameEngine( GameScene *scene, GameCamera *camera, LayerGame *layer );
	// default destructor
	~GameEngine();

	// update -function
	virtual void update( cocos2d::ccTime dt );

	// get master scene
	GameScene *getGameScene();
	// get game camera
	GameCamera *getGameCamera();
	// get master layer
	LayerGame *getGameLayer();
	// get physics world
	b2World *getGameWorld();

	// get physic object engine
	GamePhysicObjectEngine *getPhysicObjectEngine();

	// get current game state
	GameState getCurrentGameState();

	// get current money
	int getCurrentMoney();
	// modify current money
	void modifyCurrentMoney( int amount );

private:
	// pointer to the main game scene
	GameScene *mGameScene;
	// pointer to the game camera
	GameCamera *mGameCamera;
	// main game layer
	LayerGame *mGameLayer;

	// level engine
	GameLevelEngine *mGameLevelEngine;

	// clouds
	GameClouds *mGameClouds;

	// main physics world
	b2World *mGameWorld;

	// current money left 
	int mCurrentMoney;

	// all the different engines in the game
	std::vector< GameAbstractEngine* > *mEngines;
	// pointers to different engines
	GamePhysicObjectEngine *mPhysicObjectEngine;

	// checks for winning condionts
	GameState mOldGameState;
	GameState checkGameState();
};

#endif